package com.thinkingstar.iads.projectcenter.entity.dao;

import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;

import com.thinkingstar.iads.common.serviceImpl.EntityRepositoryServiceImpl;
import com.thinkingstar.iads.common.utils.CommonDateUtil;
import com.thinkingstar.iads.common.utils.StringUtil;
import com.thinkingstar.iads.projectcenter.entity.PcProjectFile;
import com.thinkingstar.iads.projectcenter.entity.PcProjectInfo;

@IocBean(args = {"refer:dao"})
public class DaoPcProjectFile extends EntityRepositoryServiceImpl<PcProjectFile>{

	public DaoPcProjectFile(Dao dao) {
		super(dao);
	}
	
	//保存文件上传记录并将id返回
	public String saveFile(String relative_path , String upload_file_name){
		String file_name = StringUtil.getFileNameByPath(relative_path);
		String suffix = file_name.substring(file_name.lastIndexOf(".")+1);
		PcProjectFile pcProjectFile = new PcProjectFile(upload_file_name,relative_path,suffix);
		pcProjectFile.setCreate_time(CommonDateUtil.getDateTime());
		PcProjectFile result = insert(pcProjectFile);
		if(result != null){
			return result.getId();
		}
		return null;
	}
	

}
